package com.sherpas.android.component.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.MotionEvent;

import com.sherpas.android.R;
import com.sherpas.android.component.activity.base.BaseActivity;

public class SplashActivity extends BaseActivity {
	private final int DELAY_TIME = 3000;
	CountDownTimer mCountDownTimer;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public void setContentView() {
		setContentView(R.layout.activity_splash);
	}

	@Override
	public void initComponents() {
		mCountDownTimer = new CountDownTimer(DELAY_TIME, DELAY_TIME) {

			@Override
			public void onTick(long millisUntilFinished) {

			}

			@Override
			public void onFinish() {
				stop();
			}
		};
		mCountDownTimer.start();
	}

	@Override
	public void addListeners() {
		// TODO Auto-generated method stub

	}

	private void stop() {
		startActivity(new Intent(SplashActivity.this, LoginActivity.class));
		finish();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			mCountDownTimer.cancel();
			stop();
		}
		return super.onTouchEvent(event);
	}

}
